const path = require('path')
const merge = require('webpack-merge')
const config = require('./webpack.base.js')

const serverConfig = {
	target: 'node',
	entry: './src/server/index.js',
	output: {
		filename: 'bundle.js',
		path: path.resolve(__dirname, 'build')
	},
	module: {
		rules: [
			{
				test: /\.css$/,
				include: /src/,
				use: ['isomorphic-style-loader', {
					loader: 'css-loader',
					options: {
						importLoaders: 1,
						modules: true,
						localIdentName: '[name]_[local]_[hash:base64:5]'
					}
				}]
			},
			{
				test: /\.css$/,
				include: [
					/node_modules/,
					/normalize\.css/
				],
				use: ['isomorphic-style-loader', {
					loader: 'css-loader',
					options: {
						importLoaders: 1,
						modules: false,
						localIdentName: '[name]_[local]_[hash:base64:5]'
					}
				}]
			},
			{
				test: /\.less$/,
				include: [
			    /src/,
			    /node_modules/ //增加此项
			  ],
				use: ['isomorphic-style-loader', {
					loader: 'css-loader',
					options: {
						importLoaders: 1,
						modules: true,
						localIdentName: '[name]_[local]_[hash:base64:5]'
					}
				}, 'less-loader']
			}
		]
	}
}

module.exports = merge(config, serverConfig)